import Context from './LoadView.vue'
import { createVNode, render } from 'vue' //导入需要的vue函数

function showToast() {
    this.container = null;
}
let time = null;
showToast.show = function(){
    //如果存在 60秒后清除,防止异常导致遮罩一直显示关闭不掉的情况
    if(this.container){
        clearInterval(time)
        let _this = this;
        time = setInterval(function() {
            _this.container && _this.hide();
        }, 6000);
    }else{
        this.container = document.createElement('div');
        const vm = createVNode(Context,{}, null)
        render(vm, this.container)
        document.body.appendChild(this.container);
    }
}
showToast.hide = function(){
    this.container && document.body.removeChild(this.container);
    this.container = null;
    clearInterval(time)
    time = null;
}

export default showToast
